package com.douwong.student.fragment;

import android.annotation.SuppressLint;
import android.content.Context;

import com.douwong.student.base.BaseQuestionAnswerChoiceFragment;
import com.douwong.student.model.QaTopic;

import java.util.ArrayList;
import java.util.List;


/**
 * @autor yichao
 * @time 2016/10/2713:44
 * @des  问答互动选择题
 */
@SuppressLint("ValidFragment")
public class QuestionAnswerChoiceFragment extends BaseQuestionAnswerChoiceFragment {
    private String chooseLastAnswer="";

    public QuestionAnswerChoiceFragment(Context context, QaTopic qaTopic) {
        super(context,qaTopic);
    }

    @Override
    protected void setSlectViewState(String str) {
        for (int i = 0; i < linearlayouts.length; i++) {
            if (str.equals(chart[i])) {
                if (mContenView.findViewById(linearlayouts[i]).isSelected()) {
                    mContenView.findViewById(linearlayouts[i]).setSelected(false);
                    chooseLastAnswer="";
                } else {
                    mContenView.findViewById(linearlayouts[i]).setSelected(true);
                    chooseLastAnswer = str;
                }
            } else {
                mContenView.findViewById(linearlayouts[i]).setSelected(false);
            }
        }

    }

    @Override
    public List<String> getAnswerInfo() {
        List<String> list=new ArrayList<>();
        list.add(chooseLastAnswer);
        return list;
    }

    @Override
    public void setCommitStatue() {
        for (int i = 0; i < linearlayouts.length; i++) {
            mContenView.findViewById(linearlayouts[i]).setClickable(false);
        }
    }


}
